<?php
/**
 * 管理员修改密码验证类
 * User: worry
 * Date: 2018/3/12
 * Time: 9:35
 */
namespace backend\models\validators;
class UserModifyPass Extends \yii\base\Model
{
    public $id;
    public $old_password_hash;
    public $password_hash;
    public $repeat_password_hash;

    /**
     * 验证规则
     * @return array
     */
    public function rules()
    {
        return [
            ['id', 'integer'],
            [['id', 'old_password_hash', 'password_hash', 'repeat_password_hash'], 'required'],
            ['repeat_password_hash', 'compare', 'compareAttribute' => 'password_hash'],
            ['password_hash', 'match', 'pattern' => '/^[\w]{6,20}$/', 'message' => '密码位数必须大于6，小于20'],
        ];
    }

    /**
     * 属性备注
     * @return array
     */
    public function attributes()
    {
        return [
            'id' => '管理员ID',
            'old_password_hash' => '旧密码',
            'password_hash' => '新密码',
            'repeat_password_hash' => '确认新密码',
        ];
    }


}